﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GTCAS.WebApplication.Filters;
using GTCAS.WebApplication.Models;
using GTCAS.Business;
using GTCAS.CommonLib.Entities;

namespace GTCAS.WebApplication.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Trang chủ";

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Chương trình quản lý mạng cáp.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult MenuLayout()
        {
            if (Session[Common.Constants.KEY_SESSION.TINHTHANH_INFO] != null && Session[Common.Constants.KEY_SESSION.USER_INFO] != null)
            {
                long id_tinhthanh = (long)Session[Common.Constants.KEY_SESSION.TINHTHANH_INFO];
                var currentUser = (Models.UserInfoModel)Session[Common.Constants.KEY_SESSION.USER_INFO];
                var menuBO = new MenuBO(id_tinhthanh);
                var lstMenu = menuBO.GetListByUser(currentUser.Username);
                return PartialView("_MenuPartial", lstMenu);
            
            }
            else
            {
                return PartialView("_MenuPartial", null);
            }
        }
    }
}
